package cn.fangline.base.util;

import com.google.common.base.Charsets;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import org.apache.commons.lang.math.RandomUtils;

import java.io.File;
import java.net.URL;
import java.util.List;

/**
 * Created by 抽离 on 2017/5/26 0026.
 */
public class HeaderUtil {

    private static List<String> userAgents = null;
    static {
        try {
            URL url = Resources.getResource("userAgents");
            File file = new File(url.getPath());
            userAgents = Files.readLines(file, Charsets.UTF_8);
        } catch(Exception ex) {}
    }

    public static  String getUserAgent(){
        return userAgents.get(RandomUtils.nextInt(25));
    }
    
    public static void main(String[] args){
        System.out.println("----------=" + getUserAgent());
    }
}
